package com.ruoyi.xp.supply.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xp.supply.domain.SupplyWarehouseGoods;
import com.ruoyi.xp.supply.service.ISupplyWarehouseGoodsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虾皮仓库库存明细Controller
 * 
 * @author chdx
 * @date 2022-12-29
 */
@Controller
@RequestMapping("/supply/SupplyWarehouseGoods")
public class SupplyWarehouseGoodsController extends BaseController
{
    private String prefix = "supply/SupplyWarehouseGoods";

    @Autowired
    private ISupplyWarehouseGoodsService supplyWarehouseGoodsService;

    @RequiresPermissions("supply:SupplyWarehouseGoods:view")
    @GetMapping()
    public String SupplyWarehouseGoods()
    {
        return prefix + "/SupplyWarehouseGoods";
    }

    /**
     * 查询虾皮仓库库存明细列表
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SupplyWarehouseGoods supplyWarehouseGoods)
    {
        startPage();
        List<SupplyWarehouseGoods> list = supplyWarehouseGoodsService.selectSupplyWarehouseGoodsList(supplyWarehouseGoods);
        return getDataTable(list);
    }

    /**
     * 导出虾皮仓库库存明细列表
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:export")
    @Log(title = "虾皮仓库库存明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SupplyWarehouseGoods supplyWarehouseGoods)
    {
        List<SupplyWarehouseGoods> list = supplyWarehouseGoodsService.selectSupplyWarehouseGoodsList(supplyWarehouseGoods);
        ExcelUtil<SupplyWarehouseGoods> util = new ExcelUtil<SupplyWarehouseGoods>(SupplyWarehouseGoods.class);
        return util.exportExcel(list, "虾皮仓库库存明细数据");
    }

    /**
     * 新增虾皮仓库库存明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存虾皮仓库库存明细
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:add")
    @Log(title = "虾皮仓库库存明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SupplyWarehouseGoods supplyWarehouseGoods)
    {
        return toAjax(supplyWarehouseGoodsService.insertSupplyWarehouseGoods(supplyWarehouseGoods));
    }

    /**
     * 修改虾皮仓库库存明细
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:edit")
    @GetMapping("/edit/{supplyWarehouseGoodsId}")
    public String edit(@PathVariable("supplyWarehouseGoodsId") String supplyWarehouseGoodsId, ModelMap mmap)
    {
        SupplyWarehouseGoods supplyWarehouseGoods = supplyWarehouseGoodsService.selectSupplyWarehouseGoodsBySupplyWarehouseGoodsId(supplyWarehouseGoodsId);
        mmap.put("supplyWarehouseGoods", supplyWarehouseGoods);
        return prefix + "/edit";
    }

    /**
     * 修改保存虾皮仓库库存明细
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:edit")
    @Log(title = "虾皮仓库库存明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SupplyWarehouseGoods supplyWarehouseGoods)
    {
        return toAjax(supplyWarehouseGoodsService.updateSupplyWarehouseGoods(supplyWarehouseGoods));
    }

    /**
     * 删除虾皮仓库库存明细
     */
    @RequiresPermissions("supply:SupplyWarehouseGoods:remove")
    @Log(title = "虾皮仓库库存明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(supplyWarehouseGoodsService.deleteSupplyWarehouseGoodsBySupplyWarehouseGoodsIds(ids));
    }
}
